/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/



#pragma once

#include "../基本类型.h"

template<typename T>
inline T f_getSun(T* v, uint32 num) {
	T 和 = 0.0;

	for (uint32 i = 0; i < num; ++i) {
		和 += v[i];
	}

	return 和;
}


template<typename T>
inline T f_getMean(T* v, uint32 num) {
	T 平均值 = 0.0;

	for (uint32 i = 0; i < num; ++i) {
		平均值 += v[i];
	}

	return 平均值 / num;
}

template<typename T>
inline T f_getStd(T* v, uint32 num, const T 平均值) {
	T 标准差 = 0.0;

	for (uint32 i = 0; i < num; ++i) {
		float32 u = v[i] - 平均值;

		标准差 += u * u;
	}

	return sqrtf(标准差 / num);
}


inline float32 lerp(float32 a, float32 b, float32 f) {
	return a + f * (b - a);
}


